package ca.ets.osgi.uiservice_model;

import java.util.Hashtable;

public class ListRoomUsers {

	//private constructor
	private static ListRoomUsers instance;
	
	//private hashtable of RoomUser
	private Hashtable<String,RoomUser> hTable = new Hashtable<String,RoomUser>();
	
	//making a valid instance
	public static ListRoomUsers getInstance(){
		if(instance ==null)
			instance = new ListRoomUsers();
		return instance;
		
	}

	/**
	 * @return the hTable
	 */
	public Hashtable<String, RoomUser> gethTable() {
		return hTable;
	}

	/**
	 * @param hTable the hTable to set
	 */
	public void sethTable(Hashtable<String, RoomUser> hTable) {
		this.hTable = hTable;
	}
	
	/**
	 * Add an RoomUser to the list
	 * @param ID
	 * @param room
	 */
	public void addRoomUserToTable(String ID,RoomUser room){
		if(ID !=null && room !=null)
		this.hTable.put(ID, room);
	}
	
	/**
	 * Remove an RoomUser to the list
	 * @param ID
	 */
	public void removeRoomUserFromTable(String ID){
		this.hTable.remove(ID);
	}
	
	/**
	 * Return a RoomUser
	 * @param ID
	 * @return
	 */
	public RoomUser getRoomUser(String ID){
		return this.hTable.get(ID);
	}
	
	/**
	 * 
	 * @param ID
	 * @return
	 */
	public boolean isRoomUserInTable(String ID){
		boolean response =false;
		RoomUser room  = this.hTable.get(ID);
		if(room!=null)
			response = true;
		return response;
	}
	
	
}
